public class LogIn {
    private String userName = "admin";
    private String passWord = "123456";
    public void loginInfo(String userName,String passWord) throws UserNameException{
        if (!this.userName.equals(userName)){
//            System.out.println("用户名错误！");
//            return;
//            throw new UserNameException();//当自定义的异常继承于非受查异常时
            throw new UserNameException(userName+"用户名错误");
        }
        if (!this.passWord.equals(passWord)){
//            System.out.println("密码错误！");
//            return;
            throw new PasswordException(passWord+"密码错误！");
        }
        System.out.println("登录成功！");
    }

    public static void main(String[] args) {
        LogIn logIn = new LogIn();
        try {
            logIn.loginInfo("admin11","123456");
        }catch (UserNameException e){
            e.printStackTrace();
        }
    }
}
